#!/bin/bash

#    lambda-tube (λ-tube) - A youtube search API and application in scheme.
#    Copyright (C) 2008  Abhishek Mishra
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.

#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

###############################################################################

#    This is the build script for creating an executable for the lambda-tube
#    application on a Linux machine, which has PLT Scheme installed.

LT_DIST_TOP_FOLDER=`pwd`/dist
DIST_START_TIME=`date +%Y%m%d%H%M%S`
LT_DIST_FOLDER=$LT_DIST_TOP_FOLDER/$DIST_START_TIME/lambda-tube
LT_DIST_TARBALL=lambda-tube-$DIST_START_TIME.tar
LT_DIST_TGZ=$LT_DIST_TARBALL.gz

echo "--lambda-tube stand-alone distribution archive will be "$LT_DIST_TGZ 

mkdir -p $LT_DIST_FOLDER

### Compile the application into a MrEd executable
mzc --gui-exe lambda-tube ./src/lt-search.scm

### Create a stand-alone distribution of the executable
mzc --exe-dir $LT_DIST_FOLDER lambda-tube
rm lambda-tube

### Copy src, license, and build files to target
mkdir $LT_DIST_FOLDER/src
cp -R src/*.scm $LT_DIST_FOLDER/src

mkdir $LT_DIST_FOLDER/i18n
cp  i18n/languages $LT_DIST_FOLDER/i18n
cp  i18n/en_US $LT_DIST_FOLDER/i18n
cp  i18n/hi_IN $LT_DIST_FOLDER/i18n

cp gpl.txt $LT_DIST_FOLDER
cp build.sh $LT_DIST_FOLDER
cp build.bat $LT_DIST_FOLDER
cp MrEd-License.txt $LT_DIST_FOLDER

### tar and gzip
cd $LT_DIST_FOLDER/..
tar -cf $LT_DIST_TOP_FOLDER/$LT_DIST_TARBALL *
gzip $LT_DIST_TOP_FOLDER/$LT_DIST_TARBALL
cd -

echo "--build complete--"
